<?php
class Controller_Estimate extends  Controller_Template {
	public function __construct($req, $res) {
		$this->template = "smarty:estimate/all_estimate";
		parent::__construct($req, $res);
	}

	/**
	 * 获得所有的历史结算数据
	 *
	 *
	 */	
	public function action_history()
	{
	 	$mer_id = User::current_user_id();
		$tno = date('Ym');
		$rs = array();
        $vendor    = new Promotion_Vendor(user::current_user_id());
		$activites = $vendor->get_activity($mer_id);
		foreach($activites as $key => $val)
		{
			$activity = Promotion_Activity::info($val['activity_id']);
			$budget = Estimate_Budget::budget_info($tno,$val['activity_id'],$mer_id);
			$rs[$key]['month'] = $budget['no'];
			$rs[$key]['money'] = $budget['money'];
			$rs[$key]['counts'] = $budget['counts'];
			$rs[$key]['pay_type'] = $budget['pay_type'];
			$rs[$key]['activity_name'] = $activity['name'];
			$rs[$key]['status'] = $budget['status'];
		}

		$this->template->set_filename('smarty:estimate/budgets');
		$this->template->set('globa_site_type','merchant');
		$this->template->set('rs',$rs);
	}

    /**
     * 当前结算信息
     */
    public function action_current ()
    {
    }



#    public function action_activity_info()
#    {
#        $info = TuiGuang_Activity::info(1);
#        print_r($info);
#    }
#

#    public function action_channel_add ()
#    {
#        $name = '测试渠道C';
#        $key  = 'test.chn.0xC';
#        $desc = 'hello,world';
#        $merid = 1;
#        $id = TuiGuang_Channel::add($name, $key, $desc, $merid);
#        echo $id;
#    }
#
#    public function action_channel_info ($channel_id)
#    {
#        $info = TuiGuang_Channel::info($channel_id);
#        print_r($info);
#    }
#
#    public function action_tuiguang_has ($activity_id, $channel_id)
#    {
#        var_dump(TuiGuang::has_channel($activity_id, $channel_id));
#    }
#
#    public function action_tuiguang_add ($activity_id, $channel_id)
#    {
#        var_dump(TuiGuang::add_2_activity($activity_id, $channel_id));
#    }
#

#    public function action_tuiguang_close ($activity_id, $channel_id)
#    {
#        $tg = new TuiGuang($activity_id, $channel_id);
#        $target_url = 'http://www.sssss';
#        var_dump($tg->close());
#    }
#
#    public function action_import ()
#    {
#        $tool = new TuiGuang_Effect_Import;
#        $tool->import('2012-12-18');
#        $tool->import();
#    }
#
#    public function action_budget_build()
#    {
#        $budget = new Estimate_Budget;
#        $month  = '2012-12';
#        $start_day = '2012-12-01';
#        $stop_day  = '2012-12-31';
#        $budget->build($month, $start_day, $stop_day);
#    }
#
#    public function action_budget_project_confirm($budget_id, $ratio = NULL)
#    {
#        $budget = new Estimate_Budget($budget_id);
#        $budget->confirm_by_project($ratio);
#    }
#
#    public function action_budget_business_confirm($budget_id, $ratio = NULL)
#    {
#        $budget = new Estimate_Budget($budget_id);
#        $budget->confirm_by_business($ratio);
#    }
#
#
#    public function action_financial_build ()
#    {
#        $merchant_id = 1;
#        $activity_id = 1;
#        $activity_pay_type = 'CPA';
#        $activity_pay_param = 'newbie';
#        $pay_by_count = 150;
#        $pay_by_money = 22500;
#        $pay_no       = '2012-12';
#
#        $rs = Estimate_Financial::build($merchant_id, $activity_id, $activity_pay_type, $activity_pay_param, $pay_by_count, $pay_by_money, $pay_no);
#        var_dump($rs);
#    }
#
#    public function action_financial_status ($bill_id, $status)
#    {
#        $financial = new Estimate_Financial($bill_id);
#        $financial->set_status($status);
#    }
#
#	public function action_test()
#	{
#		print_r('this is my test');
#
#	}
}
